package com.sun.filesigndemo.common.statusCode;

import java.io.Serializable;

/**
 * 结果状态码
 * 
 * @author winkey
 */
public class ResultStatus implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 状态码
	 */
	private final Integer code;

	/**
	 * 状态消息
	 */
	private final String msg;

	/**
	 * 构造方法
	 * 
	 * @param code
	 *            状态码
	 * @param msg
	 *            状态消息
	 */
	public ResultStatus(Integer code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	/**
	 * 获得状态码
	 * 
	 * @return 状态码
	 */
	public Integer getCode() {
		return code;
	}

	/**
	 * 获得状态消息
	 * 
	 * @return 状态消息
	 */
	public String getMsg() {
		return msg;
	}

	public ResultStatus format(Object... objects) {
		return new ResultStatus(this.code, String.format(msg, objects));
	}

	public ResultStatus append(Object... objects) {
		String newMsg = msg;
		for (Object item : objects) {
			newMsg = newMsg + item.toString();
		}
		return new ResultStatus(this.code, newMsg);
	}

}
